<template>

  <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
    <el-card class="box-card">
      <span>基本信息</span>
      <div class="text item">
        <el-form-item label="订单号">
          <el-input v-model="ruleForm.orderNumber" disabled></el-input>
        </el-form-item>
        <el-form-item label="申请时间">
          <el-input :value="getDate(ruleForm.addTime)" disabled></el-input>
        </el-form-item>
        <el-form-item label="订单状态">
          <el-input v-model="ruleForm.statusString" disabled></el-input>
        </el-form-item>
        <el-form-item label="汽车总数量">
          <el-input v-model="ruleForm.carSumNumber" disabled></el-input>
        </el-form-item>
        <el-form-item label="融资经销商">
          <el-input v-model="ruleForm.dealerName" disabled></el-input>
        </el-form-item>
     
        <el-form-item label="融资总金额(元)">
          <el-input :value="ruleForm.mortgageSumMoney| toFixed2" disabled></el-input>
          <span class="convertCurrency">{{ruleForm.mortgageSumMoney|convertCurrency}}</span>
        </el-form-item>

         <el-form-item label="初始融资周期">
          <el-input v-model="ruleForm.durationName" disabled></el-input>
        </el-form-item>


        <el-form-item label="初始融资利率" >
          <el-input  :value="ruleForm.mortgageInterestRate| toFixed4" disabled></el-input>
        </el-form-item>
         

    
        <el-form-item label="收款账户名">
          <el-input v-model="ruleForm.accountName"  disabled></el-input>
        </el-form-item>
        <el-form-item label="收款账号">
          <el-input v-model="ruleForm.accountNumber"  disabled></el-input>
        </el-form-item>
        <el-form-item label="开户行">
          <el-input v-model="ruleForm.openningBank"  disabled></el-input>
        </el-form-item>
   
        <el-form-item label="资源审核意见">
          <el-input v-model="ruleForm.resourceAuditOpinion" disabled></el-input>
        </el-form-item>
        <el-form-item label="物管验车意见">
          <el-input v-model="ruleForm.propertyInspectionOpinion" disabled></el-input>
        </el-form-item>
        <el-form-item label="风控审核意见">
          <el-input v-model="ruleForm.riskAuditOpinion" disabled></el-input>
        </el-form-item>


        <el-form-item label="退单理由">
          <el-input v-model="ruleForm.backRemark" disabled></el-input>
        </el-form-item>
        <el-form-item label="退单申请时间">
          <el-input :value="getDate(ruleForm.backTime)" disabled></el-input>
        </el-form-item>
        <el-form-item label="物管验车审核时间">
          <el-input :value="getDate(ruleForm.propertyInspectionTime)" disabled></el-input>
        </el-form-item>


      </div>
    </el-card>
    <el-form-item label="退单是否通过" prop="status" style='marginTop:20px'>
      <el-radio v-model="ruleForm.status" label="-10010" :disabled="dialogSendData.isAdd">通过</el-radio>
      <el-radio v-model="ruleForm.status" label="-10020" :disabled="dialogSendData.isAdd">不通过</el-radio>
    </el-form-item>
    <el-card class="box-card">
      <el-form-item label="退单审核意见" prop="riskManagementReviewRemark">
        <el-input v-model="ruleForm.riskManagementReviewRemark" placeholder="必填，100字限制。" :maxlength='100' :disabled="dialogSendData.isAdd"></el-input>
      </el-form-item>
    </el-card>
    <el-form-item class='align'>
      <el-button type="primary" @click="resetForm('ruleForm')">返回</el-button>
      <el-button  type="success" @click="submitForm('ruleForm')" v-if="!dialogSendData.isAdd">提交</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
  import qiniu from '@/views/qiniu/upload';
  import agentHttp from '@/utils/agentHttp.js';
  import {
    require,
    prop,
    decimalTwo,
  } from '@/utils/rules.js' //表单验证规则
    import {timestampToTime} from '@/utils/index.js';
    

  export default {      
    data() {
      return {
        ruleForm: {
           status:''
        },
        rules: {
          status:[require("退单是否通过")],
          riskManagementReviewRemark: [require("风控审核意见")]
        },
        radio: '1'
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate(valid => {
          if (valid) {
            this.submitOrder();

          } else {
            console.log("error submit!!");
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
        this.dialogSendData.dialogFormVisible = false;
      },

      initData() { //获取数据
        agentHttp.get(`adminApi/admin/mortgage_order_risk/refund_order_detail/${this.mortgageOrderExtendId}`).then((data) => {
          this.ruleForm =  Object.assign({},data.data,this.ruleForm);
         
         
        })
      },
         //提交数据
        submitOrder(){
         this.ruleForm.mortgageOrderExtendId=this.mortgageOrderExtendId;
            agentHttp.post(`adminApi/admin/mortgage_order_risk/refund_order_submit`,this.ruleForm).then((res)=>{
                if(res.success){  
                  this.$message.success(res.data||"提交成功");                  
                  this.$emit('Refresh',null);
                  this.dialogSendData.dialogFormVisible = false;
                } 
             })
        },
        getDate(time){
          return timestampToTime(time)
        }

    },
    props: {
      dialogSendData: {
        type: Object
      },
       mortgageOrderExtendId: {
        type: Number
      }
    },
    mounted() {
      this.initData();
    },
    components: {
      qiniu
    }
  };

</script>

<style lang="scss" scoped>
  .text {
    font-size: 14px;
  }

  .item {
    margin-bottom: 18px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }

  .clearfix:after {
    clear: both;
  }

  .box-card {
    margin-top: 20px;
  }

  .align {
    margin: 50px auto 0;
    text-align: center;
  }

</style>

